package com.boot2.core.model;

import com.boot2.core.LongBaseEntity;
import lombok.Data;
import lombok.ToString;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * @author zhangweilin
 * @version V1.0
 * @date 2016-7-15 11:32:39
 * @description 各服务对应的token
 */
@Data
@ToString(callSuper = true)
@Entity
@Table(name = "ms_token")
@SQLDelete(sql = "update ms_token set is_deleted = 1 where id = ?")
@Where(clause = "is_deleted = 0")
@DynamicInsert // 加上此注解，可以只添加有值的字段
@DynamicUpdate // 此注解，是指，会先查，然后跟参数对比，不一样的就更新，所以并不是有值更新，如果db中有值，参数里没值，那么db中的值会清空
public class MsToken extends LongBaseEntity {
    /**
     *
     */
    private static final long serialVersionUID = 2136438298510238741L;

    /**
     * 服务名称
     */
    private String serviceName;

    /**
     * 各服务对应的token
     */
    private String token;
}
